<?
class GinContactlogController extends BaseController{

    function __construct() {
    	parent::__construct();
    }

    // SCAFFOLD ACCESS
	public function index() {
		$gin_contactlog = new GinContactlogModel();
		$response['results']= $gin_contactlog->get_all();
    	$this->render("scaffold/gincontactlog_list",$response);
	}
	
	public function add() {
	    $gin_contactlog = new GinContactlogModel();
		$response = $gin_contactlog->to_array();
		$this->render("scaffold/gincontactlog_add",$response);
	}
	
	public function edit($id) {
		$gin_contactlog = new GinContactlogModel();
		$gin_contactlog->id = $id;
		$gin_contactlog->load();
		$response['gin_contactlog'] = $gin_contactlog;
		$this->render("scaffold/gincontactlog_edit",$response);
	}
  
// CRUD OPERATIONS   
    public function create() {
    	$gin_contactlog = new GinContactlogModel();
    	$gin_contactlog->init();
    	$result = $gin_contactlog->create();
    	if ($result == 0) {
    		redirect("/scaffold/gincontactlog");
    	} else {
    		// error
    		$response = $gin_contactlog->to_array();
    		$this->render("scaffold/gincontactlog_add");
    	}
    }
    
    public function update() {
    	$gin_contactlog = new GinContactlogModel();
    	$gin_contactlog->init();
    	$result = $gin_contactlog->update();
    	if ($result == 0) {
    		redirect("/scaffold/gincontactlog");
    	} else {
    		// error
    		$response = $gin_contactlog->to_array();
    		$this->render("scaffold/gincontactlog_edit");
    	}
    }
    
    public function delete() {
    
    	$gin_contactlog = new GinContactlogModel();
    	$gin_contactlog->init();
    	$result = $gin_contactlog->delete();
    	if ($result == 0) {
    		redirect("/scaffold/gincontactlog");
    	} else {
    		// error
    		die("unable to delete id ".$this->id);
    	}
    }

    public function test() {
        // to do later
    }
}
    
